"use strict";
cc._RF.push(module, '193eexy63tPk6WfhQphQZS+', 'login_resetPassword_pop');
// scripts/loginPop/login_resetPassword_pop.js

"use strict";

/**
 * 登录模块
 * 功能：重置密码界面
 */
cc.Class({
    extends: cc.Component,

    properties: {
        edPassword: {
            default: null,
            type: cc.EditBox
        },
        edPasswordNew: {
            default: null,
            type: cc.EditBox
        },

        _verifyCode: "",
        _account: ""
    },

    // use this for initialization
    onLoad: function onLoad() {},

    initData: function initData(data) {
        this._verifyCode = data.password;
        this._account = data.account;
    },

    onTrue: function onTrue() {
        if (Utils.checkInput(null, this.edPassword.string, null, this.edPasswordNew.string, true)) {

            var self = this;
            var recv = function (ret) {
                ComponentsUtils.unblock();
                if (ret.Code !== 0) {
                    cc.error(ret.Msg);
                    ComponentsUtils.showTips(ret.Msg);
                } else {
                    window.Notification.emit("onPasswordSuccess", data);
                    this.onClose();
                }
            }.bind(this);

            var data = {
                Token: User.getLoginToken(),
                Mobile: this._account,
                Pwd: this.edPassword.string,
                VerifyCode: this._verifyCode
            };
            CL.HTTP.sendRequestRet(DEFINE.HTTP_MESSAGE.RESETPWDUNLOGIN, data, recv.bind(this), "POST");
            ComponentsUtils.block();
        }
    },

    onTextChangePwd: function onTextChangePwd(text, editbox, customEventData) {
        var txt = text;
        if (txt == "") {
            this.pwd = txt;
        } else {
            var re = txt.replace(/\s+/g, "");
            editbox.string = re;
            txt = re;
            this.pwd = txt;
        }
    },

    onTextChangePwd1: function onTextChangePwd1(text, editbox, customEventData) {
        var txt = text;
        if (txt == "") {
            this.pwd1 = txt;
        } else {
            var re = txt.replace(/\s+/g, "");
            editbox.string = re;
            txt = re;
            this.pwd1 = txt;
        }
    },

    onClose: function onClose() {
        this.node.getComponent("Page").backAndRemove();
    }

});

cc._RF.pop();